import Vue from 'vue'
import Vuex from 'vuex'
import local from '../utils/localstorage'

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    userInfo: local.get('USERINFO'),
    isLogin: local.get('ISLOGIN'),
    isDetail: local.get('ISDETAIL')
  },
  mutations: {
    setLogin (state, val) {
      local.save('ISLOGIN', val)
      state.isLogin = val
    },
    setUser (state, val) {
      local.save('USERINFO', val)
      state.userInfo = val
    },
    setDetail (state, val) {
      local.save('ISDETAIL', val)
      state.isDetail = val
    }
  },
  actions: {
  },
  modules: {
  },
  getters: {
    isLogin: state => state.isLogin,
    userInfo: state => state.userInfo
  }
})
